package models

import "github.com/beego/beego/v2/client/orm"

type ErpEntryMiddle struct {
	Id          int64
	EntryId     int64
	Products    *ErpProducts `orm:"rel(fk);null;on_delete(do_nothing)"`
	PurchaseNum int64
	Attribute   string
}

func (a *ErpEntryMiddle) TableName() string {
	return ErpEntryMiddleTableName()
}

func ErpEntryMiddleTableName() string {
	return TableName("erp_entry_middle")
}

func ErpEntryMiddleList(entry_id int64, typeid ...int) []*ErpEntryMiddle {
	list := make([]*ErpEntryMiddle, 0)
	o := orm.NewOrm().QueryTable(ErpEntryMiddleTableName()).RelatedSel("Products")
	o = o.Filter("entry_id", entry_id)
	if len(typeid) > 0 {
		o = o.Filter("Products__typeid__in", typeid)
	}
	o.All(&list)
	return list
}
